/******************************************************
 *                                                     
 *              Score System               
 *                                                     
 *******************************************************/

/**
 * ExportServlet.java
 *
 * 网页的响应Servlet
 *
 * @author sundy
 * @version 0.0.1
 * lastModified 2011-01-01
 */

package com.sundy.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.sundy.core.Context;
import com.sundy.core.Utility;
import com.sundy.tools.ExcelProcess;

public class ExportServlet extends AbstractServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = -7122423596445464100L;

	public ExportServlet() {
	}

	protected void doGet(Context context, HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		doPost(context, request, response);
	}

	protected void doPost(Context context, HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		if (context.getCurrentUser().getAdmin() != 1) {
			request.setAttribute("infor", "该功能仅限于管理员使用");
			Utility.showJSP(request, response, "/information.jsp");
			return;
		}
		String idStr = request.getParameter("id");
		if (idStr == null || idStr.trim().equals("")) {
			Utility.showError(request, response, "参数错误！");
			return;
		}
		ExcelProcess.export(Integer.valueOf(idStr));
		out.print("导出完毕！");
	}
}
